<template>
  <div class="bigbox">
      <div class="top">
          <el-form ref="form" label-width="80px">
      <el-form-item label="属性分类">
        <el-select v-model="form.region" placeholder="请选择分类">
          <el-option :label="item.name" :value="item.id" v-for="item in getCategoryLists" :key="item.id"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="属性名称">
    <el-input v-model="form.name"></el-input>
  </el-form-item>

  <el-form-item>
            <el-button type="primary" @click="addFn">保存</el-button>
            <el-button>取消</el-button>
          </el-form-item>
    </el-form>
      </div>
  </div>
</template>

<script>
import {addAttrbute,getCategoryLists} from '../../request/httpApi'
export default {
  data() {
    return {
      form: {
        region: "",
        name:''
      },
      getCategoryLists:[]
    };
  },

  created(){
      // 分类渲染
      getCategoryLists().then((res)=>{
        //   console.log(res);
          this.getCategoryLists = res.data;
      })
  },
  methods:{
      addFn(){
          addAttrbute({
          name:this.form.name,
          attribute_category_id:this.form.region
      }).then((res)=>{
          console.log(res);
      })
      }
  }
};
</script>

<style lang="less" scoped>
.bigbox {
  background: #fff;
  .top{
      padding-top: 20px;
      padding-bottom: 30px;
      .el-input {
    //   margin-left: 15px;
      width: 217px;
      margin-right: 15px;
      /deep/ .el-input__inner {
        height: 36px;
        line-height: 36px;
        border-radius: 5px;
      }
    }
  }
}
</style>
